<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<ProjectMadaktariMVC.Models.Patient>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	View Episode
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <% Html.RenderPartial("PatientDetails"); %>
    <% ProjectMadaktariMVC.Models.Episode episode = (ProjectMadaktariMVC.Models.Episode)ViewData["episode"]; %>
    <div id="episodeDetails">
         <ul>
            <li><a href="#Admit">Admit</a></li>
            <li><a href="#Procedure">Procedure</a></li>
            <li><a href="#Discharge">Discharge</a></li>
            <li><a href="#FollowUp">Follow Up</a></li>
        </ul>
        
        <div id="Admit">
            <%= Html.ActionLink("Edit", "EditEpisode", "Patient", null, null, "Admit", new { patientId = Model.patientID, episodeId = episode.episodeID}, null) %> | 
            <%= Html.ActionLink("Episode List", "View", new { id = Model.patientID}) %>
            <div class="form_block">
                <span class="form_label">Admit Date</span>
                <%= episode.admitDate == null ? "--" : ((DateTime)episode.admitDate).ToString("MM/dd/yyyy") %>
            </div>
            
            <div class="form_block">
                <span class="form_label">Hospital</span>
                <%= episode.Hospital == null ? "" : episode.Hospital.hospitalName%>
            </div>
            
            <div class="form_block">
                <span class="form_label">Referal Location</span>
                <%= episode.ReferalLocation == null ? "" : episode.ReferalLocation.referalLocationName %>
            </div>
            
            <div class="form_block">
                <span class="form_label">Diagnoses</span>
                <%= episode.GetDiagnosesList() %>
            </div>
            <div class="form_block">
                <span class="form_label">Diagnosis Other</span>
                <%= episode.diagnosisOther %>
            </div>
            <div class="form_block">
                <span class="form_label">Concomitant Diagnosis 1</span>
                <%= episode.ConcomitantDiagnosi == null ? "" : episode.ConcomitantDiagnosi.concomitantDiagnosisName %>
            </div>
            <div class="form_block">
                <span class="form_label">Concomitant Diagnosis 2</span>
                <%= episode.ConcomitantDiagnosi1 == null ? "" : episode.ConcomitantDiagnosi1.concomitantDiagnosisName %>
            </div>
            <div class="form_block">
                <span class="form_label">Surgical History</span>
                <%= episode.surgicalHistory %>
            </div>
            <div class="form_block">
                <span class="form_label">Case Comments</span>
                <%= episode.caseComments %>
            </div>
            <div class="form_block">
                <span class="form_label">Image Findings</span>
                <%= episode.imageFindings %>
            </div>
        </div>
        <div id="Procedure">
            <%= Html.ActionLink("Add New Procedure", "AddProcedure", new {episodeId = episode.episodeID })%>
            <div id="procedureList">
                <% foreach (ProjectMadaktariMVC.Models.Procedure procedure in episode.Procedures)
                   {
                       if (procedure.procedureID != 0)
                       {%>
                    <h3><a href="#"><%= (procedure.date == null ? "" : ((DateTime)procedure.date).ToString("MM/dd/yyyy")) + " " + (procedure.procedureTypeID == null ? "" : procedure.ProcedureType.procedureTypeName)%></a></h3>
                    <div><% Html.RenderPartial("ViewProcedure", procedure); %></div>
                <% }
                   } %>
            </div>
        
        </div>
        <div id="Discharge">
        <%= Html.ActionLink("Edit", "EditEpisode", "Patient", null, null, "Discharge", new { patientId = Model.patientID, episodeId = episode.episodeID}, null) %> | 
            <%= Html.ActionLink("Episode List", "View", new { id = Model.patientID}) %>
            <div class="form_block">
                <span class="form_label">
                    Discharge Date
                </span>
                <%= episode.dischargeDate == null ? "--" : ((DateTime)episode.dischargeDate).ToString("MM/dd/yyyy") %>
            </div>
            <div class="form_block">
                <span class="form_label">Post-Op Status</span>
                <%= episode.postOpStatus %>
            </div>
            
            <div class="form_block">
            <span class="form_label">Days Post Op</span>
            <% if (episode.dischargeDate == null)
               { %>
                <em>number of days will be automatically calculated</em>
            <%}
               else
               { %>
                <%= (DateTime.Today - (DateTime)episode.dischargeDate).Days%> Days
            <%} %>
        </div>
        
        <div class="form_block">
            <span class="form_label">Post-Op Complications</span>
            <%= episode.complications.ToString().ToUpper() %>
        </div>
        <br />
        <div class="form_block">
            <span class="form_label">Complication Notes</span>
            <%= episode.complicationNotes %>
        </div>
        
        <div class="form_block">
            <span class="form_label">Length of Stay</span>
            <% if (episode.admitDate == null || episode.dischargeDate == null)
               {%>
                <em>length of stay will be automatically calculated</em>
            <%}
               else
               { %>
                <%= ((DateTime)episode.dischargeDate - (DateTime)episode.admitDate).Days %> Days
            <%} %>
        </div>
        </div>
        
        <div id="FollowUp">
        <%= Html.ActionLink("Edit", "EditEpisode", "Patient", null, null, "FollowUp", new { patientId = Model.patientID, episodeId = episode.episodeID}, null) %> | 
            <%= Html.ActionLink("Episode List", "View", new { id = Model.patientID}) %>
            <div class="form_block">
                <span class="form_label">Date of Follow Up</span>
                <%= episode.followUpDate == null ? "--" : ((DateTime)episode.followUpDate).ToString("MM/dd/yyyy") %>
            </div>
            <div class="form_block">
                <span class="form_label">Follow Up Status</span>
                <%= episode.followUpStatus %>
            </div>    
        </div>
    </div>
    
    <script type="text/javascript">
        $(function() {
            $('#episodeDetails').tabs();
            $('#procedureList').accordion({ collapsible: true, active: false, autoHeight: false });
        });
    </script>

</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="Header" runat="server">
</asp:Content>

<asp:Content ID="Content4" ContentPlaceHolderID="TableSubheader" runat="server">
</asp:Content>
